const Koa = require('koa');
const app = new Koa();
const path = require('path');
const io = require('socket.io');
const static = require('koa-static');
const cors = require('@koa/cors')
const getPublicIP = require('./utils/getPublic');
const robotSocketCk = require('./router/robotSocket');
const port = 8081;

const server = require('http').Server(app.callback());
const socket = io(server,{
  cors:{
    origin:"*"
  }
});

const robotSocket = socket.of('/robot');

robotSocketCk(robotSocket);

app.use(static(path.join(__dirname,'./public')));
app.use(cors());
server.listen(process.env.PORT || port, () => {
    getPublicIP(port);
})